import { userInfoUpdate as userInfoUpdateApi } from "../api/api";
import { nickNameGet, avatarGet } from "../storage/userInfo"

const userInfoUpdateParamsGet = () => {
    const nickName = nickNameGet();
    const avatarUrl = avatarGet();
    if (!nickName || !avatarUrl) {
        throw new Error("昵称或头像不能为空");
    }
    return { nickName, avatarUrl };
}

export const userInfoUpdate = () => {
    try {
        const userInfo = userInfoUpdateParamsGet();
        userInfoUpdateApi(userInfo).then(res => {
            if (!res) return;
            console.log('userInfoUpdateApi-----')
            console.log(res)
        })
    } catch (error) {
        console.log('ERR-userInfoUpdate:' + error.message)
    }
}